package com.qriver.modules.consumer;

import java.util.Map;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.qriver.common.entity.UserInfo;

@RestController
@RequestMapping("admin")
public class AdminController {
	
	@RequestMapping("/token/{token}")
	@ResponseBody
    public String authentication(@PathVariable(required = false) String token) {
		System.out.println("core - authentication");
		if(token != null && token.equals("abc")) {
			return "true";
		}else {
			return "false";
		}
    }
	@RequestMapping(value = "/user/validate", method = RequestMethod.POST)
    public @ResponseBody UserInfo validate(@RequestBody Map<String,String> body){
		UserInfo info = new UserInfo();
		info.setName("测试用户");
		info.setId("test_1");
		info.setUsername(body.get("username"));
		info.setPassword(body.get("password"));
		return info;
		//return permissionService.validate(body.get("username"),body.get("password"));
    }
}
